package com.ruoyi.web.controller.crm;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BsStreet;
import com.ruoyi.system.service.IBsStreetService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 街道设置Controller
 * 
 * @author ruoyi
 * @date 2020-11-05
 */
@RestController
@RequestMapping("/system/street")
public class BsStreetController extends BaseController
{
    @Autowired
    private IBsStreetService bsStreetService;

    /**
     * 查询街道设置列表
     */
    @PreAuthorize("@ss.hasPermi('system:street:list')")
    @GetMapping("/list")
    public TableDataInfo list(BsStreet bsStreet)
    {
        startPage();
        List<BsStreet> list = bsStreetService.selectBsStreetList(bsStreet);
        return getDataTable(list);
    }

    /**
     * 导出街道设置列表
     */
    @PreAuthorize("@ss.hasPermi('system:street:export')")
    @Log(title = "街道设置", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BsStreet bsStreet)
    {
        List<BsStreet> list = bsStreetService.selectBsStreetList(bsStreet);
        ExcelUtil<BsStreet> util = new ExcelUtil<BsStreet>(BsStreet.class);
        return util.exportExcel(list, "street");
    }

    /**
     * 获取街道设置详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:street:query')")
    @GetMapping(value = "/{streetId}")
    public AjaxResult getInfo(@PathVariable("streetId") Long streetId)
    {
        return AjaxResult.success(bsStreetService.selectBsStreetById(streetId));
    }

    /**
     * 新增街道设置
     */
    @PreAuthorize("@ss.hasPermi('system:street:add')")
    @Log(title = "街道设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BsStreet bsStreet)
    {
        return toAjax(bsStreetService.insertBsStreet(bsStreet));
    }

    /**
     * 修改街道设置
     */
    @PreAuthorize("@ss.hasPermi('system:street:edit')")
    @Log(title = "街道设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BsStreet bsStreet)
    {
        return toAjax(bsStreetService.updateBsStreet(bsStreet));
    }

    /**
     * 删除街道设置
     */
    @PreAuthorize("@ss.hasPermi('system:street:remove')")
    @Log(title = "街道设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{streetIds}")
    public AjaxResult remove(@PathVariable Long[] streetIds)
    {
        return toAjax(bsStreetService.deleteBsStreetByIds(streetIds));
    }
}
